package com.yowasa.xiuxian.engine.battle.strategy.drop.all;

import com.google.common.collect.Lists;
import com.yowasa.xiuxian.annoations.BS;
import com.yowasa.xiuxian.engine.battle.strategy.CalAbility;
import com.yowasa.xiuxian.engine.battle.strategy.InherentStrategy;
import com.yowasa.xiuxian.entity.bo.battle.BattleContent;
import com.yowasa.xiuxian.entity.bo.battle.UserBattleContent;
import com.yowasa.xiuxian.entity.bo.user.UserBO;
import com.yowasa.xiuxian.entity.enums.ElementEnum;
import com.yowasa.xiuxian.entity.enums.InherentTiming;
import com.yowasa.xiuxian.exception.HandlerException;
import com.yowasa.xiuxian.service.helper.BattleHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.util.List;

@BS(name="旅程")
@Order(1000)
@Component
public class LvCheng extends CalAbility implements InherentStrategy {
    @Autowired
    private BattleHelper battleHelper;

    @Override
    public ElementEnum getElement() {
        return null;
    }
    @Override
    public void action(UserBattleContent first, UserBattleContent second, BattleContent content) {
        int needHp = first.getBattleInfo().getHp() - first.getBattleInfo().getChp();
        int spell = (first.getBattleInfo().getAtk()/10)*first.getBattleInfo().getRestoreRate()/100;
        int can = Math.min(needHp, spell);
        first.getBattleInfo().setChp(first.getBattleInfo().getChp() + can);
        content.getMsgLog().add(first.getUserBO().getName() + "因[旅程]回复" + can + "点血量");
    }

    @Override
    public void limit(UserBO user) {
        throw new HandlerException("该战技无法直接学习，需要拥有 武器-[旅行剑] ，装备在身上时自动学会");

    }

    @Override
    public String limitDesc() {
        return "学习/使用旅程需要拥有 武器-[旅行剑] ";
    }

    @Override
    public boolean check(UserBattleContent user, BattleContent content) {
        return true;
    }

    @Override
    public String desc() {
        return "珍贵的宝箱是对旅者最好的奖励，旅者的生命意义就在于不断踏上旅程\n每次行动后回复10%攻击力的血量";
    }

    @Override
    public List<InherentTiming> getTiming() {
        return Lists.newArrayList(InherentTiming.SELF_END);
    }
}
